﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.NetworkInformation;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

namespace KingerRobot.PCRBW.Dao;
/// <summary>
/// 公共帮助类
/// </summary>
public  class CommHelper
{
    #region 判断龙门状态
    /// <summary>
    /// 判断龙门状态
    /// </summary>
    /// <param name="objIPAddress"></param>
    /// <returns></returns>
    public static bool PingIp(string objIPAddress)
    {
        AutoResetEvent waiter = new AutoResetEvent(false);
        Ping pingsender = new Ping();
        PingOptions option = new PingOptions();
        option.DontFragment = true;

        string data = "aaaaaaaaaa";
        byte[] buffer = Encoding.ASCII.GetBytes(data);
        int timeout = 100;
        try
        {
            PingReply reply = pingsender.Send(objIPAddress);
            //PingReply reply = pingsender.Send(objIPAddress, timeout, buffer, option);
            if (reply.Status == IPStatus.Success)
            {
                return true;
            }
            else
            {
                return false;
            }
        }
        catch (Exception)
        {

            return false;
        }
        finally
        {
            pingsender.Dispose();
        }

    }

    #endregion
}
